﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;

namespace repliback4.Net.Protocol.SASLMechanisms {
    public enum FailureConditions { Aborted, IncorrectEncoding, InvalidAuthzid, InvalidMechanism, MechanismTooWeak, NotAuthorized, TemporaryAuthFailure }
    public class FailureConditionEntry {
        FailureConditions failureCondition;
        XmlQualifiedName xqname;
        public FailureConditions FailureCondition {
            get { return this.failureCondition; }
            set { this.failureCondition = value; }
        }
        public XmlQualifiedName XQName {
            get { return this.xqname; }
            set { this.xqname = value; }
        }
        public String Name {
            get { return this.xqname.Name; }
        }
        public String Namespace {
            get { return this.xqname.Namespace; }
        }
    }
    public class FailureConditionRegistry : Registry<FailureConditionEntry> {

        public FailureConditionRegistry ( ) {

        }

        public FailureConditions LookupByName ( String name ) {
            return this.list.Find( new Predicate<FailureConditionEntry>(
                ( FailureConditionEntry entry ) => entry.Name == name
                ) ).FailureCondition;
        }
        public FailureConditionEntry LookupByCondition ( FailureConditions condition ) {
            return this.list.Find( new Predicate<FailureConditionEntry>(
                ( FailureConditionEntry entry ) => entry.FailureCondition == condition
                ) );
        }
    }
}
